{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "AI Suite is a light wrapper to provide a unified interface between LLM providers."
      ],
      "metadata": {
        "id": "hZq_yZRcbxdI"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Install AI Suite\n",
        "!pip install aisuite[all]"
      ],
      "metadata": {
        "id": "1mt8kgFHXMvv",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "collapsed": true,
        "outputId": "b56619e8-0dd8-4850-d3b2-1f1169672aab"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Collecting aisuite[all]\n",
            "  Downloading aisuite-0.1.5-py3-none-any.whl.metadata (4.1 kB)\n",
            "Collecting anthropic<0.31.0,>=0.30.1 (from aisuite[all])\n",
            "  Downloading anthropic-0.30.1-py3-none-any.whl.metadata (18 kB)\n",
            "Collecting groq<0.10.0,>=0.9.0 (from aisuite[all])\n",
            "  Downloading groq-0.9.0-py3-none-any.whl.metadata (13 kB)\n",
            "Requirement already satisfied: openai<2.0.0,>=1.35.8 in /usr/local/lib/python3.10/dist-packages (from aisuite[all]) (1.52.2)\n",
            "Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from anthropic<0.31.0,>=0.30.1->aisuite[all]) (3.7.1)\n",
            "Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from anthropic<0.31.0,>=0.30.1->aisuite[all]) (1.9.0)\n",
            "Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from anthropic<0.31.0,>=0.30.1->aisuite[all]) (0.27.2)\n",
            "Requirement already satisfied: jiter<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from anthropic<0.31.0,>=0.30.1->aisuite[all]) (0.6.1)\n",
            "Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from anthropic<0.31.0,>=0.30.1->aisuite[all]) (2.9.2)\n",
            "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from anthropic<0.31.0,>=0.30.1->aisuite[all]) (1.3.1)\n",
            "Requirement already satisfied: tokenizers>=0.13.0 in /usr/local/lib/python3.10/dist-packages (from anthropic<0.31.0,>=0.30.1->aisuite[all]) (0.19.1)\n",
            "Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.10/dist-packages (from anthropic<0.31.0,>=0.30.1->aisuite[all]) (4.12.2)\n",
            "Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai<2.0.0,>=1.35.8->aisuite[all]) (4.66.6)\n",
            "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (3.10)\n",
            "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (1.2.2)\n",
            "Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (2024.8.30)\n",
            "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (1.0.6)\n",
            "Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (0.14.0)\n",
            "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (0.7.0)\n",
            "Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.9.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (2.23.4)\n",
            "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /usr/local/lib/python3.10/dist-packages (from tokenizers>=0.13.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (0.24.7)\n",
            "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (3.16.1)\n",
            "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (2024.10.0)\n",
            "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (24.1)\n",
            "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (6.0.2)\n",
            "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (2.32.3)\n",
            "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (3.4.0)\n",
            "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub<1.0,>=0.16.4->tokenizers>=0.13.0->anthropic<0.31.0,>=0.30.1->aisuite[all]) (2.2.3)\n",
            "Downloading anthropic-0.30.1-py3-none-any.whl (863 kB)\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m863.9/863.9 kB\u001b[0m \u001b[31m9.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hDownloading groq-0.9.0-py3-none-any.whl (103 kB)\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m103.5/103.5 kB\u001b[0m \u001b[31m5.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hDownloading aisuite-0.1.5-py3-none-any.whl (19 kB)\n",
            "Installing collected packages: aisuite, groq, anthropic\n",
            "Successfully installed aisuite-0.1.5 anthropic-0.30.1 groq-0.9.0\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Custom Pretty Printing Function\n",
        "In this section, we define a custom pretty-printing function that enhances the readability of data structures when printed. This function utilizes Python's built-in pprint module, allowing users to specify a custom width for output formatting."
      ],
      "metadata": {
        "id": "KwFlLByRbWKi"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from pprint import pprint as pp\n",
        "# Set a custom width for pretty-printing\n",
        "def pprint(data, width=80):\n",
        "    \"\"\"Pretty print data with a specified width.\"\"\"\n",
        "    pp(data, width=width)# List of model identifiers to query\n"
      ],
      "metadata": {
        "id": "-Wf7j6abbQmw"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Setting Up API Keys\n",
        "\n",
        "Here we will securely set our API keys as environment variables. This is helpful because we don’t want to hardcode sensitive information (like API keys) directly into our code. By using environment variables, we can keep our credentials secure while still allowing our program to access them. Normally we would use a .env file to store our passwords to our enviroments, but since we are going to be working in colab we will do things a little different."
      ],
      "metadata": {
        "id": "Cce1aLBvctaL"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "BsK7GrHyV-c4",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "35fef9dc-e226-4e9d-e6c7-a597882b74f9"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Enter your GROQ API key: ··········\n"
          ]
        }
      ],
      "source": [
        "import os\n",
        "from getpass import getpass\n",
        "os.environ['GROQ_API_KEY'] = getpass('Enter your GROQ API key: ')"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Creating a Simple Chat Interaction with an AI Language Model\n",
        "This code initiates a chat interaction with a language model (specifically Groq’s LLaMA 3.2), where the model responds to the user's input. We use the aisuite library to communicate with the model and retrieve the response."
      ],
      "metadata": {
        "id": "m2mhu-VbSWfF"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import aisuite as ai\n",
        "\n",
        "# Initialize the AI client for accessing the language model\n",
        "client = ai.Client()\n",
        "\n",
        "# Define a conversation with a system message and a user message\n",
        "messages = [\n",
        "    {\"role\": \"system\", \"content\": \"You are a helpful agent, who answers with brevity.\"},\n",
        "    {\"role\": \"user\", \"content\": 'Hi'},\n",
        "]\n",
        "\n",
        "# Request a response from the model\n",
        "response = client.chat.completions.create(model=\"groq:llama-3.2-3b-preview\", messages=messages)\n",
        "\n",
        "# Print the model's response\n",
        "print(response.choices[0].message.content)"
      ],
      "metadata": {
        "id": "mBEOEq99eGjR",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "446fdba3-9072-4470-b3b8-627717013604"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "How can I assist you?\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Defining a Function to Interact with the Language Model\n",
        "\n",
        "This function, ask, streamlines the process of sending a user message to a language model and retrieving a response. It encapsulates the logic required to set up the conversation and can be reused throughout the notebook for different queries. It will not perserve any history or any continuing conversation.  \n",
        "\n"
      ],
      "metadata": {
        "id": "YJSahowjiJBE"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "def ask(message, sys_message=\"You are a helpful agent.\",\n",
        "         model=\"groq:llama-3.2-3b-preview\"):\n",
        "    # Initialize the AI client for accessing the language model\n",
        "    client = ai.Client()\n",
        "\n",
        "    # Construct the messages list for the chat\n",
        "    messages = [\n",
        "        {\"role\": \"system\", \"content\": sys_message},\n",
        "        {\"role\": \"user\", \"content\": message}\n",
        "    ]\n",
        "\n",
        "    # Send the messages to the model and get the response\n",
        "    response = client.chat.completions.create(model=model, messages=messages)\n",
        "\n",
        "    # Return the content of the model's response\n",
        "    return response.choices[0].message.content\n"
      ],
      "metadata": {
        "id": "n8DK8_RqqXFH"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "ask(\"Hi. what is capital of Japan?\")"
      ],
      "metadata": {
        "id": "FGcqY4lBjtFj",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "0520933a-8f2f-4185-a8a2-c591283482a3"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'Hello. The capital of Japan is Tokyo.'"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "string"
            }
          },
          "metadata": {},
          "execution_count": 6
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "The real value of AI Suite is the ablity to run a variety of different models.  Let's first set up a collection of different API keys which we can try out."
      ],
      "metadata": {
        "id": "wpeW6Pj6j_6H"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.environ['OPENAI_API_KEY'] = getpass('Enter your OPENAI API key: ')\n",
        "os.environ['ANTHROPIC_API_KEY'] = getpass('Enter your ANTHROPIC API key: ')"
      ],
      "metadata": {
        "id": "9_kJlkGfj_NG",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "d45074c6-bbc6-4214-df0c-6d162a176f21"
      },
      "execution_count": null,
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Enter your OPENAI API key: ··········\n",
            "Enter your ANTHROPIC API key: ··········\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "###Confirm each model is using a different provider\n"
      ],
      "metadata": {
        "id": "mfPtlJlbTY6X"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "print(ask(\"Who is your creator?\"))\n",
        "print(ask('Who is your creator?', model='anthropic:claude-3-5-sonnet-20240620'))\n",
        "print(ask('Who is your creator?', model='openai:gpt-4o'))\n"
      ],
      "metadata": {
        "id": "iHVESCGJuWWg",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "3102b43a-e754-4288-ec1d-9777791f25b6"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "I was created by Meta AI, a leading artificial intelligence research organization. My knowledge was developed from a large corpus of text, which I use to generate human-like responses to user queries.\n",
            "I was created by Anthropic.\n",
            "I was developed by OpenAI, an organization that focuses on artificial intelligence research and deployment.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Querying Multiple AI Models for a Common Question\n",
        "In this section, we will query several different versions of the LLaMA language model to get varied responses to the same question. This approach allows us to compare how different models handle the same prompt, providing insights into their performance and style."
      ],
      "metadata": {
        "id": "BWBL4D2H2B_9"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "\n",
        "models = [\n",
        "    'llama-3.1-8b-instant',\n",
        "    'llama-3.2-1b-preview',\n",
        "    'llama-3.2-3b-preview',\n",
        "    'llama3-70b-8192',\n",
        "    'llama3-8b-8192'\n",
        "]\n",
        "\n",
        "# Initialize a list to hold the responses from each model\n",
        "ret = []\n",
        "\n",
        "# Loop through each model and get a response for the specified question\n",
        "for x in models:\n",
        "    ret.append(ask('Write a short one sentence explanation of the origins of AI?', model=f'groq:{x}'))\n",
        "\n",
        "# Print the model's name and its corresponding response\n",
        "for idx, x in enumerate(ret):\n",
        "    pprint(models[idx] + ': \\n ' + x + ' ')"
      ],
      "metadata": {
        "id": "E_gg-sgYuoOb",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "d1c582ba-3471-4b0e-b9ca-317df8a1c1c5"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "('llama-3.1-8b-instant: \\n'\n",
            " ' The origins of Artificial Intelligence (AI) date back to the 1956 Dartmouth '\n",
            " 'Summer Research Project on Artificial Intelligence, where a group of '\n",
            " 'computer scientists, led by John McCarthy, Marvin Minsky, Nathaniel '\n",
            " 'Rochester, and Claude Shannon, coined the term and laid the foundation for '\n",
            " 'the development of AI as a distinct field of study. ')\n",
            "('llama-3.2-1b-preview: \\n'\n",
            " ' The origins of Artificial Intelligence (AI) date back to the mid-20th '\n",
            " 'century, when the first computer programs, which mimicked human-like '\n",
            " 'intelligence through algorithms and rule-based systems, were developed by '\n",
            " 'renowned mathematicians and computer scientists, including Alan Turing, '\n",
            " 'Marvin Minsky, and John McCarthy in the 1950s. ')\n",
            "('llama-3.2-3b-preview: \\n'\n",
            " ' The origins of Artificial Intelligence (AI) date back to the 1950s, with '\n",
            " 'the Dartmouth Summer Research Project on Artificial Intelligence, led by '\n",
            " 'computer scientists John McCarthy, Marvin Minsky, and Nathaniel Rochester, '\n",
            " 'marking the birth of AI as a formal field of research. ')\n",
            "('llama3-70b-8192: \\n'\n",
            " ' The origins of Artificial Intelligence (AI) can be traced back to the 1950s '\n",
            " 'when computer scientist Alan Turing proposed the Turing Test, a method for '\n",
            " 'determining whether a machine could exhibit intelligent behavior equivalent '\n",
            " 'to, or indistinguishable from, that of a human. ')\n",
            "('llama3-8b-8192: \\n'\n",
            " ' The origins of Artificial Intelligence (AI) can be traced back to the '\n",
            " '1950s, when computer scientists DARPA funded the development of the first AI '\n",
            " 'programs, such as the Logical Theorist, which aimed to simulate human '\n",
            " 'problem-solving abilities and learn from experience. ')\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Querying Different AI Providers for a Common Question\n",
        "In this section, we will query multiple AI models from different providers to get varied responses to the same question regarding the origins of AI. This comparison allows us to observe how different models from different architectures respond to the same prompt."
      ],
      "metadata": {
        "id": "Z8pnJPdD2NL0"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# List of AI model providers to query\n",
        "providers = [\n",
        "    'groq:llama3-70b-8192',\n",
        "    'openai:gpt-4o',\n",
        "    'anthropic:claude-3-5-sonnet-20240620'\n",
        "]\n",
        "\n",
        "# Initialize a list to hold the responses from each provider\n",
        "ret = []\n",
        "\n",
        "# Loop through each provider and get a response for the specified question\n",
        "for x in providers:\n",
        "    ret.append(ask('Write a short one sentence explanation of the origins of AI?', model=x))\n",
        "\n",
        "# Print the provider's name and its corresponding response\n",
        "for idx, x in enumerate(ret):\n",
        "    pprint(providers[idx] + ': \\n' + x + ' \\n\\n')\n"
      ],
      "metadata": {
        "collapsed": true,
        "id": "j4TqhC5J1YIG",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "4a50e300-0a7a-4562-8a34-f31c4b9072d4"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "('groq:llama3-70b-8192: \\n'\n",
            " 'The origins of Artificial Intelligence (AI) can be traced back to the 1950s '\n",
            " 'when computer scientists like Alan Turing, Marvin Minsky, and John McCarthy '\n",
            " 'began exploring ways to create machines that could think and learn like '\n",
            " 'humans, leading to the development of the first AI programs and '\n",
            " 'algorithms. \\n'\n",
            " '\\n')\n",
            "('openai:gpt-4o: \\n'\n",
            " 'The origins of AI trace back to the mid-20th century, when pioneers like '\n",
            " 'Alan Turing and John McCarthy began exploring the possibility of creating '\n",
            " 'machines that could simulate human intelligence through computational '\n",
            " 'processes. \\n'\n",
            " '\\n')\n",
            "('anthropic:claude-3-5-sonnet-20240620: \\n'\n",
            " 'The origins of AI can be traced back to the 1950s when computer scientists '\n",
            " 'began exploring the concept of creating machines that could simulate human '\n",
            " 'intelligence and problem-solving abilities. \\n'\n",
            " '\\n')\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Generating and Evaluating Questions with AI Models\n",
        "In this section, we will randomly generate questions using a language model and then have two other models provide answers to those questions. The user will then evaluate which answer is better, allowing for a comparative analysis of responses from different models."
      ],
      "metadata": {
        "id": "OgPCC0y_U4WG"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import random\n",
        "\n",
        "# Initialize a list to store the best responses\n",
        "best = []\n",
        "\n",
        "# Loop to generate and evaluate questions\n",
        "for _ in range(20):\n",
        "    # Shuffle the providers list to randomly select models for each iteration\n",
        "    random.shuffle(providers)\n",
        "\n",
        "    # Generate a question using the first provider\n",
        "    question = ask('Please generate a short question that is suitable for asking an LLM.', model=providers[0])\n",
        "\n",
        "    # Get answers from the second and third providers\n",
        "    answer_1 = ask('Please give a short answer to this question: ' + question, model=providers[1])\n",
        "    answer_2 = ask('Please give a short answer to this question: ' + question, model=providers[2])\n",
        "\n",
        "    # Print the generated question and the two answers\n",
        "    pprint(f\"Original text:\\n  {question}\\n\\n\")\n",
        "    pprint(f\"Option 1 text:\\n  {answer_1}\\n\\n\")\n",
        "    pprint(f\"Option 2 text:\\n  {answer_2}\\n\\n\")\n",
        "\n",
        "    # Store the provider names and the user's choice of the best answer\n",
        "    best.append(str(providers) + ', ' + input(\"Which is best 1 or 2. 3 if indistinguishable: \"))"
      ],
      "metadata": {
        "collapsed": true,
        "id": "fMx-TfLk09ft",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "56153c03-a1e6-4b72-fd16-b36197ccb5ee"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "('Original text:\\n'\n",
            " \"  Here's a short question suitable for asking an LLM:\\n\"\n",
            " '\\n'\n",
            " 'What are the potential benefits and risks of artificial intelligence in '\n",
            " 'healthcare?\\n'\n",
            " '\\n')\n",
            "('Option 1 text:\\n'\n",
            " '  **Benefits:**\\n'\n",
            " '1. Improved diagnostics and personalized treatment plans.\\n'\n",
            " '2. Increased efficiency in administrative tasks.\\n'\n",
            " '3. Faster drug discovery and development.\\n'\n",
            " '4. Enhanced patient monitoring and support.\\n'\n",
            " '\\n'\n",
            " '**Risks:**\\n'\n",
            " '1. Privacy and data security concerns.\\n'\n",
            " '2. Potential biases in AI algorithms.\\n'\n",
            " '3. Over-reliance on AI systems by healthcare professionals.\\n'\n",
            " '4. Ethical and accountability issues in decision-making.\\n'\n",
            " '\\n')\n",
            "('Option 2 text:\\n'\n",
            " '  The potential benefits of artificial intelligence (AI) in healthcare '\n",
            " 'include:\\n'\n",
            " '\\n'\n",
            " '* Improved diagnosis accuracy and speed\\n'\n",
            " '* Enhanced patient outcomes through personalized medicine\\n'\n",
            " '* Increased efficiency and reduced costs through automation\\n'\n",
            " '* Better disease prevention and detection\\n'\n",
            " '* Enhanced research capabilities and new treatment discoveries\\n'\n",
            " '\\n'\n",
            " 'However, there are also potential risks, such as:\\n'\n",
            " '\\n'\n",
            " '* Bias in AI decision-making due to flawed data or algorithms\\n'\n",
            " '* Job displacement of healthcare professionals\\n'\n",
            " '* Cybersecurity risks to patient data\\n'\n",
            " '* Dependence on technology leading to deskilling of healthcare workers\\n'\n",
            " '* Unintended consequences of AI-driven decision-making that may not align '\n",
            " 'with human values.\\n'\n",
            " '\\n'\n",
            " 'These benefits and risks highlight the need for responsible development, '\n",
            " 'deployment, and oversight of AI in healthcare.\\n'\n",
            " '\\n')\n",
            "Which is best 1 or 2. 3 if indistinguishable: 3\n",
            "('Original text:\\n'\n",
            " '  What are the potential applications of large language models in '\n",
            " 'healthcare?\\n'\n",
            " '\\n')\n",
            "('Option 1 text:\\n'\n",
            " '  Large language models have numerous potential applications in healthcare, '\n",
            " 'including:\\n'\n",
            " '\\n'\n",
            " '1. **Clinical Decision Support**: Providing doctors with accurate diagnoses, '\n",
            " 'treatment options, and medication recommendations.\\n'\n",
            " '2. **Medical Text Analysis**: Analyzing large amounts of medical literature, '\n",
            " 'patient records, and clinical notes to identify patterns and insights.\\n'\n",
            " '3. **Patient Engagement**: Generating personalized health summaries, '\n",
            " 'communicating medical information in simple language, and facilitating '\n",
            " 'patient-provider communication.\\n'\n",
            " '4. **Disease Surveillance**: Monitoring social media and online platforms '\n",
            " 'for disease outbreaks and tracking epidemiological trends.\\n'\n",
            " '5. **Medical Writing Assistance**: Assisting healthcare professionals in '\n",
            " 'generating medical reports, discharge summaries, and other documents.\\n'\n",
            " '6. **Chatbots and Virtual Assistants**: Offering patients timely support and '\n",
            " 'answers to medical queries.\\n'\n",
            " '7. **Research and Development**: Accelerating biomedical research by '\n",
            " 'analyzing large datasets, identifying research gaps, and suggesting '\n",
            " 'potential areas of investigation.\\n'\n",
            " '\\n'\n",
            " 'These applications have the potential to improve healthcare outcomes, reduce '\n",
            " 'costs, and enhance patient experiences.\\n'\n",
            " '\\n')\n",
            "('Option 2 text:\\n'\n",
            " '  Large language models in healthcare could potentially be used for:\\n'\n",
            " '\\n'\n",
            " '1. Clinical decision support\\n'\n",
            " '2. Medical literature analysis and summarization\\n'\n",
            " '3. Patient triage and symptom checking\\n'\n",
            " '4. Medical education and training\\n'\n",
            " '5. Automated medical coding and documentation\\n'\n",
            " '6. Drug discovery and development\\n'\n",
            " '7. Personalized treatment recommendations\\n'\n",
            " '8. Health-related chatbots for patient engagement\\n'\n",
            " '9. Medical research and hypothesis generation\\n'\n",
            " '10. Natural language processing of electronic health records\\n'\n",
            " '\\n'\n",
            " 'These applications could help improve efficiency, accuracy, and '\n",
            " 'accessibility in various aspects of healthcare.\\n'\n",
            " '\\n')\n"
          ]
        },
        {
          "output_type": "error",
          "ename": "KeyboardInterrupt",
          "evalue": "Interrupted by user",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-14-d17783dc1f7c>\u001b[0m in \u001b[0;36m<cell line: 7>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     22\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     23\u001b[0m     \u001b[0;31m# Store the provider names and the user's choice of the best answer\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 24\u001b[0;31m     \u001b[0mbest\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mproviders\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m', '\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Which is best 1 or 2. 3 if indistinguishable: \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
            "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m    849\u001b[0m                 \u001b[0;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    850\u001b[0m             )\n\u001b[0;32m--> 851\u001b[0;31m         return self._input_request(str(prompt),\n\u001b[0m\u001b[1;32m    852\u001b[0m             \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    853\u001b[0m             \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m    893\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    894\u001b[0m                 \u001b[0;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 895\u001b[0;31m                 \u001b[0;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Interrupted by user\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    896\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    897\u001b[0m                 \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Invalid Message:\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
          ]
        }
      ]
    }
  ]
}